Skip to content

feat: Add HTML class customization settings#85

Merged
justinmayer merged 6 commits intopelican-plugins:mainfrom
tstreule:patch-1
Mar 17, 2025
Merged

feat: Add HTML class customization settings#85
justinmayer merged 6 commits intopelican-plugins:mainfrom
tstreule:patch-1

Conversation

@tstreule
Copy link
Contributor

@tstreule tstreule commented Feb 10, 2025

Introduce the settings IMAGE_PROCESS_ADD_CLASS and IMAGE_PROCESS_CLASS_PREFIX, allowing customization of the image's CSS class image-process-<transform>.

  • IMAGE_PROCESS_ADD_CLASS controls whether the image-process-<transform> CSS class is added to images after processing. By default, this setting is enabled (True). If disabled, no class is added to the image.

  • IMAGE_PROCESS_CLASS_PREFIX allows customization of the class prefix. The default prefix is image-process-, but this can be changed to a custom value.

tstreule and others added 2 commits February 10, 2025 15:07
Introduce `IMAGE_PROCESS_REMOVE_CLASS` setting, allowing the removal of
`image-process-<transform>` CSS classes after image processing. These
classes are user-assigned to trigger transformations, but once processed,
they may no longer be needed. If enabled, the class is removed, and if it
was the only class, the `class` attribute is deleted entirely.
@patrickfournier patrickfournier self-requested a review March 11, 2025 14:26
Copy link
Contributor

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to add a new setting, I think my inclination would be to add a IMAGE_PROCESS_ADD_CLASS setting instead.

And instead of a Boolean, maybe make it a string prefix that defaults to the current image-process-<transform> pattern. That way the class name could be customized to the user's liking, or the class addition could be omitted entirely by configuring the setting to any "falsy" value.

What does everything think about this alternative approach?

@patrickfournier
Copy link
Collaborator

@justinmayer I feel we should have two separate settings for what you are proposing: one to define the image-process- prefix (solving the problem where a website that already has image-process-something classes wants to start using the ImageProcess plugin), and one to disable outputting ImageProcess classes (answering the need to have a cleaner HTML output, with no unused CSS classes).

@tstreule
Copy link
Contributor Author

If you like, I can adjust the code by adding a IMAGE_PROCESS_CLASS_PREFIX (default: image-process-) and IMAGE_PROCESS_ADD_CLASS (default: True) setting.

- Renamed `IMAGE_PROCESS_REMOVE_CLASS` to `IMAGE_PROCESS_ADD_CLASS` (default: `True`)
- Introduced `IMAGE_PROCESS_CLASS_PREFIX` (default: `"image-process-"`) for class name customization
- Updated documentation to reflect these changes
@minchinweb
Copy link
Member

It looks okay to me. Generally, I am hesitant to add too many configuration settings, but I can see the use case.

Thank you as well for updating the documentation!

Ideally, there should be a test for this (to make sure it works as expected as doesn't get broken in future updates). If it's trivial to add, go ahead and add it to this PR. Otherwise, we can merge this PR and let's raise an issue to track adding the tests.

@tstreule
Copy link
Contributor Author

@minchinweb I added some tests for the new settings.

I also added a RELEASE.md file, following your latest PR #92.

@justinmayer
Copy link
Contributor

I have been traveling but will review this in the next day or two. It shouldn’t be merged in its current form, if only because the release file will need modifications to incorporate the other changes that have been merged since the last release.

@justinmayer justinmayer changed the title feat: add IMAGE_PROCESS_REMOVE_CLASS setting feat: Add IMAGE_PROCESS_REMOVE_CLASS setting Mar 17, 2025
Copy link
Contributor

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks to @tstreule for the enhancement and to @patrickfournier and @minchinweb for reviewing! 🏅

As a very minor suggestion, in the future it would be better to put the unrelated README whitespace/formatting changes in a separate commit and pull request. That makes it easier when reviewing the commit history, using the Git blame feature, etc. But please don't let this minor suggestion detract from the excellent work here, which is greatly appreciated! 😁

@justinmayer justinmayer changed the title feat: Add IMAGE_PROCESS_REMOVE_CLASS setting feat: Add HTML class customization settings Mar 17, 2025
@justinmayer justinmayer merged commit fbcf2a4 into pelican-plugins:main Mar 17, 2025
7 checks passed
@tstreule tstreule deleted the patch-1 branch March 17, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants